﻿using System;
using System.Collections.Generic;
using System.Reflection;

using Matchingo.Common.Types.Interfaces;

namespace Matchingo.Models.DefaultImageSetResources
{
	public class BackgroundSetResources : IBackgroundSetResources
	{
        // URI path is made up of AssemblyName, SubFolder, Filename
        private const string URI_PATH = "/{0};component/{1}/{2}";		

		private const string SET_NAME_NETHERLANDS = "Netherlands";
		private const string SET_NAME_ATLANTA_ZOO = "Atlanta Zoo";
		private const string SET_NAME_KEUKENHOF_GARDENS = "Keukenhof Gardens";

		private const string FOLDER_NETHERLANDS_BACKGROUNDS = "Netherlands_Backgrounds";
		private const string FOLDER_ATLANTA_ZOO_BACKGROUNDS = "AtlantaZoo_Backgrounds";
		private const string FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS = "KeukenhofGardens_Backgrounds";

		public List<string> BackgroundSetNames
		{
            get
            {
                List<string> cardSets = new List<string>();
                cardSets.Add(SET_NAME_ATLANTA_ZOO);
                cardSets.Add(SET_NAME_KEUKENHOF_GARDENS);
                cardSets.Add(SET_NAME_NETHERLANDS);

                return cardSets;
            }
		}

		public Dictionary<string, List<Uri>> BackgroundSetsProvided
		{
            get
            {
                Dictionary<string, List<Uri>> backgroundSets = new Dictionary<string, List<Uri>>();

                List<Uri> netherlandsBackgrounds = new List<Uri>()
                {
                    FormatUri(FOLDER_NETHERLANDS_BACKGROUNDS, "background_P1050838.jpg"),
                    FormatUri(FOLDER_NETHERLANDS_BACKGROUNDS, "background_P1040953.jpg"),
                    FormatUri(FOLDER_NETHERLANDS_BACKGROUNDS, "background_P1050177.jpg")
                };

                List<Uri> atlantaZooBackgrounds = new List<Uri>()
                {
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "blackApe_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "elephant_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "goldbluebird_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "kangaroo_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "panda_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "redmonkey_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "tiger_cropped.jpg"),
                    FormatUri(FOLDER_ATLANTA_ZOO_BACKGROUNDS, "turtle_cropped.jpg")
                };

                List<Uri> keukenhofBackgrounds = new List<Uri>()
                {
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050643.JPG"),
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050676.JPG"),
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050721.JPG"),
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050731.JPG"),
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050734.JPG"),
                 FormatUri(FOLDER_KEUKENHOF_GARDENS_BACKGROUNDS, "P1050756.JPG")
                };

                backgroundSets.Add(SET_NAME_ATLANTA_ZOO, atlantaZooBackgrounds);
                backgroundSets.Add(SET_NAME_KEUKENHOF_GARDENS, keukenhofBackgrounds);
                backgroundSets.Add(SET_NAME_NETHERLANDS, netherlandsBackgrounds);

                return backgroundSets;
            }
		}

		private static Uri FormatUri(string foldername, string filename)
		{
            string fullAssemblyName = Assembly.GetExecutingAssembly().ToString();
            string assemblyName = fullAssemblyName.Substring(0, fullAssemblyName.IndexOf(','));

            return new Uri(string.Format(URI_PATH, assemblyName, foldername, filename), UriKind.Relative);
		}
	}
}